#include "StdAfx.h"
#include "Scheduler.h"
#include "LeafOperator.h"
Scheduler* Scheduler::scheduler = NULL;
Scheduler::Scheduler()
{
	 
	
}


Scheduler::~Scheduler(void)
{
}
Scheduler* Scheduler::getInstance()
{
	if(scheduler==NULL)
	{
		scheduler = new Scheduler();
	}
	return scheduler;
}
void Scheduler::setOperatorList(std::list<boost::shared_ptr<Operator> >operatorList)
{
	this->operatorList = operatorList;
	this->it = this->operatorList.begin();
}
void Scheduler::getNextOperatorToExecute(boost::shared_ptr<Operator>& op, int& executionTimes)
{
	if(it==this->operatorList.end())
	{
		it = this->operatorList.begin();
	}

	op = *it;
	 
	if(typeid(*op)==typeid(LeafOperator))
	{
		executionTimes = 2;
	}
	else
	{
		executionTimes = defualtExecutionTimes;
	}
	
	it++;
	
}
bool Scheduler::isEmpty(void)
{
	return this->operatorList.size()==0;
}